// LoginUI.java - 身份选择入口
package com.bank.ui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

public class LoginUI extends JFrame {
    public LoginUI() {
        setTitle("银行系统 - 身份选择");
        setSize(300, 150);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo(null);

        // 创建主面板
        JPanel mainPanel = new JPanel(new BorderLayout(20, 20));
        mainPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        // 标题
        JLabel titleLabel = new JLabel("请选择您的身份", SwingConstants.CENTER);
        titleLabel.setFont(new Font("微软雅黑", Font.BOLD, 16));
        mainPanel.add(titleLabel, BorderLayout.NORTH);

        // 按钮面板
        JPanel buttonPanel = new JPanel(new GridLayout(1, 2, 15, 0));

        // 客户按钮
        JButton customerButton = new JButton("客户登录");
        customerButton.addActionListener(this::openCustomerLogin);
        buttonPanel.add(customerButton);

        // 管理员按钮
        JButton adminButton = new JButton("管理员登录");
        adminButton.addActionListener(this::openAdminLogin);
        buttonPanel.add(adminButton);

        mainPanel.add(buttonPanel, BorderLayout.CENTER);
        setContentPane(mainPanel);
    }

    private void openCustomerLogin(ActionEvent e) {
        CustomerLoginUI customerLoginUI = new CustomerLoginUI();
        customerLoginUI.setVisible(true);
        dispose(); // 关闭当前窗口
    }

    private void openAdminLogin(ActionEvent e) {
        AdminLoginUI adminLoginUI = new AdminLoginUI();
        adminLoginUI.setVisible(true);
        dispose(); // 关闭当前窗口
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(() -> {
            LoginUI loginUI = new LoginUI();
            loginUI.setVisible(true);
        });
    }
}